package ym.ai.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;
import ym.ai.service.IChatAssistant;
import ym.vo.BaseResult;

/**
 * ai接口
 */
@RequestMapping("/ai")
@RestController
public class ChatController {
    @Autowired
    IChatAssistant iChatAssistant;

    /**
     * 聊天
     *
     * @param message
     * @return
     */
    @GetMapping("/chat")
    public BaseResult chat(String message) {
        String chat = iChatAssistant.chat(message);
        return BaseResult.ok(chat);
    }

    /**
     * 聊天【流式输出】
     *
     * @param message
     * @return
     */
    @GetMapping("/chat/stream")
    public Flux<String> streamChat(String message) {
        return iChatAssistant.streamChat(message);
    }
}
